#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <strings.h>
#include <string.h>



static const char *device = "/dev/spidev0.0";
static uint8_t mode = 0; /* SPI 通信使用全双工，设置 CPOL＝0，CPHA＝0。 */
static uint8_t bits = 8; /* ８ｂiｔｓ读写，MSB first。*/
static uint8_t lsb = 1; /*设备传输的时候是否先传输低比特位*/
static uint32_t speed = 100*1000;/* 设置传输速度 */
static uint16_t delay = 0;
static int g_SPI_Fd = 0;

#define SPI_DEBUG 1

int SPI_LookBackTest(void);

static void pabort(const char *s)
{
    perror(s);
    abort();
}

/**
 * @brief 发送数据并接收
 * 
 * @param TxBuf 
 * @param RxBuf 
 * @param len 
 * @param outputLog 
 * @return int 
 */
int SPI_Transfer(uint8_t *TxBuf, uint8_t *RxBuf, int len, int outputLog)
{
    int ret = 0;

    
    return ret;
}

int SPI_Write(uint8_t *TxBuf, int len)
{
    int ret = 0;

    return ret;
}

int SPI_Read(uint8_t *RxBuf, int len)
{
    int ret = 0;

    return ret;
}

int SPI_Open(void)
{
    int fd;
    int ret = 0;


    return ret;
}

int SPI_Close(void)
{
    int fd = g_SPI_Fd;

    return 0;
}

int SPI_LookBackTest(void)
{
    int ret = 0;

    return ret;
}

/* 
int main(void)
{
    int ret;

    ret = SPI_Open();
    printf("************************* ret = %d***********************\n", ret);

    //unsigned char buf[3] = {0xf3, 0x76, 0x59};
    //SPI_Write(buf, 3);

    SPI_LookBackTest();

    SPI_Close();

    return 0;
} */